package com.tsx.demo;

import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfWriter;
import com.itextpdf.layout.Document;
import com.itextpdf.layout.element.List;
import com.itextpdf.layout.element.Paragraph;

import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Demo4 {
    public static void main(String[] args) {
        String para = "This is para";
        Path path = Paths.get(Constants.dest, "demo4.pdf");
        try (OutputStream os = Files.newOutputStream(path)) {
            PdfWriter pdfWriter = new PdfWriter(os);
            PdfDocument pdfDocument = new PdfDocument(pdfWriter);
            Document document = new Document(pdfDocument);
            Paragraph paragraph = new Paragraph(para);
            List list = new List();
            list.add("Java");
            list.add("JavaFX");
            list.add("Apache Tika");
            list.add("OpenCV");
            list.add("WebGL");
            list.add("Coffee Script");
            list.add("Java RMI");
            list.add("Apache Pig");
            document.add(paragraph);
            document.add(list);
            document.close();
            pdfDocument.close();
            pdfWriter.close();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
